home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Milan_1991 / Devcon91.1 / Libraries / Workbench / AppWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  3.5 KB  |  105 lines

  1. /***********************************************************************
  2.  *                                                                     *
  3.  *                            COPYRIGHTS                               *
  4.  *                                                                     *
  5.  *   Copyright (c) 1990  Commodore-Amiga, Inc.  All Rights Reserved.   *
  6.  *                                                                     *
  7.  **********************************************************************/
  8.  
  9. /*
  10.  * Code to test AppWindow feature of Workbench
  11.  */
  12.  
  13. #include <intuition/intuition.h>
  14. #include <exec/memory.h>
  15. #include <workbench/startup.h>
  16. #include <workbench/workbench.h>
  17.  
  18. #include <stdio.h>
  19.  
  20. #include <clib/exec_protos.h>
  21. #include <clib/intuition_protos.h>
  22. #include <clib/icon_protos.h>
  23. #include <clib/wb_protos.h>
  24. #include <clib/dos_protos.h>
  25.  
  26. struct IntuitionBase *IntuitionBase;
  27. struct WorkbenchBase *WorkbenchBase;
  28. struct IconBase *IconBase;
  29.  
  30. void            main(void);
  31.  
  32. void 
  33. main(void)
  34. {
  35.   struct MsgPort *msgport;
  36.   struct Window  *win;
  37.   struct AppWindow *aw;
  38.   struct IntuiMessage *imsg;
  39.   struct AppMessage *amsg;
  40.   struct WBArg   *argptr;
  41.  
  42.   ULONG           id = 1, userdata = 0;
  43.   BOOL            done = FALSE;
  44.   int             i;
  45.  
  46.   printf("aw: enter\n");
  47.  
  48.   if (IntuitionBase = OpenLibrary("intuition.library", 36)) {
  49.     if (WorkbenchBase = OpenLibrary("workbench.library", 36)) {
  50.       if (IconBase = OpenLibrary("icon.library", 36)) {
  51.     if (msgport = CreateMsgPort()) {
  52.       if (win = OpenWindowTags(NULL,
  53.                    WA_Left, 0,
  54.                    WA_Top, 1,
  55.                    WA_Width, 160,
  56.                    WA_Height, 50,
  57.                    WA_IDCMP, CLOSEWINDOW,
  58.                    WA_Flags, WINDOWCLOSE | WINDOWDRAG,
  59.                    WA_Title, "AppWindow",
  60.                    TAG_END)) {
  61.             printf("aw: calling AddAppWindow...\n");
  62.             if (aw = AddAppWindow(id, userdata, win, msgport, NULL)) {
  63.                   printf("aw: ok, aw = %lx, going to sleep\n", aw);
  64.           do {
  65.             Wait(1 << win->UserPort->mp_SigBit | 1 << msgport->mp_SigBit);
  66.             while (imsg = (struct IntuiMessage *) GetMsg(win->UserPort)) {
  67.               if (imsg->Class = CLOSEWINDOW)
  68.             done = TRUE;
  69.               ReplyMsg((struct Message *) imsg);
  70.             }
  71.             while (amsg = (struct AppMessage *) GetMsg(msgport)) {
  72.               printf("aw: appmsg=%lx, Type=%ld, ID=%ld, UserData=%ld, NumArgs=%ld\n", amsg, amsg->am_Type, amsg->am_ID, amsg->am_UserData, amsg->am_NumArgs);
  73.               argptr = amsg->am_ArgList;
  74.               for (i = 0; i < amsg->am_NumArgs; i++) {
  75.             printf("\targ(%ld): Name='%s', Lock=%lx\n", i, argptr->wa_Name, argptr->wa_Lock);
  76.             argptr++;
  77.               }
  78.               ReplyMsg((struct Message *) amsg);
  79.             }
  80.           } while (!done);
  81.                 printf("calling RemoveAppWindow\n");
  82.                 RemoveAppWindow(aw);
  83.             } else /* !aw */
  84.                 printf("Couldn't AddAppWindow\n");
  85.         CloseWindow(win);
  86.       } else        /* !win */
  87.         printf("Couldn't open window\n");
  88.           /* Make sure there are no more outstanding messages */
  89.           while(amsg = (struct AppMessage *)GetMsg(msgport))
  90.             ReplyMsg((struct Message *)amsg);
  91.       DeleteMsgPort(msgport);
  92.     } else            /* !msgport */
  93.       printf("Coulnd't create messageport\n");
  94.     CloseLibrary(IconBase);
  95.       } else            /* !IconBase */
  96.     printf("Couldn't open icon.library\n");
  97.       CloseLibrary(WorkbenchBase);
  98.     } else            /* !WorkbenchBase */
  99.       printf("Couldn't open workbench.library\n");
  100.     CloseLibrary(IntuitionBase);
  101.   } else            /* !IntuitionBase */
  102.     printf("Couldn't open intuition.library\n");
  103.   printf("aw: done\n");
  104. }
  105.